import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';
export namespace PerBusinessVehicleInfoApi {
  /** 人员车辆情况业务信息 */
  export interface BusinessVehicleInfo {
    id: number; // 主键ID
    busiId?: string; // 业务主表id
    vehicleInfoId: number; // 正式表ID，对应 per_vehicle_info.id
    employeeId: number; // 人员ID，对应 per_employee.id
    personalIdcard: string; // 个人身份证号
    purchaseDate: string | Dayjs; // 购车时间
    purchasePrice: number; // 购车价格
    brandModel: string; // 品牌型号
    plateNumber: string; // 车辆号牌
    status: number; // 是否有效（1：有效，0：无效）
    remarks: string; // 备注
    changeType: string; // 变更类型（add：新增，update：修改，delete：删除）
    changeContent: string; // 变更内容(JSON格式，记录变更前后对比，只有修改的时候记录)
    auditStatus: number; // 审核状态（0 草稿 1 审核中 2 审核完成）
    finalAuditStatus: number; // 最终审核状态：0 待审核 1 审核通过 2 审核不通过
    auditTime: string | Dayjs; // 审核完成时间
    auditor: string; // 审核人
    auditComment: string; // 审核意见
    metadata: string; // 其他参数
  }
}

/** 查询人员车辆情况业务分页 */
export function getBusinessVehicleInfoPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    PageResult<PerBusinessVehicleInfoApi.BusinessVehicleInfo>
  >('/per/business-vehicle-info/page', data, { desensitize, encrypt });
}

/** 查询人员车辆情况业务详情 */
export function getBusinessVehicleInfo(id: number) {
  return requestClient.get<PerBusinessVehicleInfoApi.BusinessVehicleInfo>(
    `/per/business-vehicle-info/get?id=${id}`,
  );
}

/** 新增人员车辆情况业务 */
export function createBusinessVehicleInfo(
  data: PerBusinessVehicleInfoApi.BusinessVehicleInfo,
) {
  return requestClient.post('/per/business-vehicle-info/create', data);
}

/** 修改人员车辆情况业务 */
export function updateBusinessVehicleInfo(
  data: PerBusinessVehicleInfoApi.BusinessVehicleInfo,
) {
  return requestClient.put('/per/business-vehicle-info/update', data);
}

/** 删除人员车辆情况业务 */
export function deleteBusinessVehicleInfo(id: number) {
  return requestClient.delete(`/per/business-vehicle-info/delete?id=${id}`);
}

/** 批量删除人员车辆情况业务 */
export function deleteBusinessVehicleInfoList(ids: number[]) {
  return requestClient.delete(
    `/per/business-vehicle-info/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出人员车辆情况业务 */
export function exportBusinessVehicleInfo(params: any) {
  return requestClient.download('/per/business-vehicle-info/export-excel', {
    params,
  });
}

/** 根据业务主表id去查询业务数据 */
export function getVehicleInfoBusiId(data: any) {
  return requestClient.post<PerBusinessVehicleInfoApi.BusinessVehicleInfo>(
    `/per/business-vehicle-info/getVehicleInfoBusiId`,
    data,
  );
}

/** 获取当前登录人车辆业务信息 */
export function getCurrentVehicleInfo(
  data,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    List<PerBusinessVehicleInfoApi.BusinessVehicleInfo>
  >('/per/business-vehicle-info/getCurrentVehicleInfo', data, {
    desensitize,
    encrypt,
  });
}
